<?php
/**
 * 登录页面
 * @since 1.0 <2015-8-25> SoChishun Added.
 */
require 'common/inc_common.php';
$config['view']['page_title'] = '登录';
if ('login' == I('action')) {
    action_login();
}
require 'common/inc_header.php';
?>
<h3>欢迎登录</h3>
<form method="post">
    <table>
        <tr><th>用户名：</th><td><input type="text" name="user_name" placeholder="用户名" required="required" /></td></tr>
        <tr><th>密码：</th><td><input type="password" name="password" placeholder="密码" required="required" /></td></tr>
        <tr><th>&nbsp;</th><td><button type="submit">登录</button><button type="reset">清空</button></td></tr>
    </table>
    <input type="hidden" name="action" value="login" />
</form>
<?php require 'common/inc_footer.php' ?>

<?php

function action_login($config) {
    $rule = array(
        'user_name' => array('validate' => 'require', 'err' => '用户名无效'),
        'password' => array('validate' => 'require', 'err' => '密码无效'),
    );
    $errs = P($rule, $data);
    if ($errs) {
        return $errs;
    }

    $db = new DB_MySQL();
    $db->connect($config['db']);
    $sql = 'select * from ';
}
?>